package com.dex4d.ui.main.model;

import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;

import com.dex4d.R;

import java.util.List;

/**
 * 作者    LiQingyi
 * 时间    2018/11/1 16:35
 * 文件    dex4d-android
 * 描述
 */
public class CoinToken implements Parcelable {

    public int pos; //在列表中的位置

    public String symbol;

    public String coins;//可变现资产
    public String coinsPrice;//可变现资产

    public String dex4d;//dex4d资产
    public String dex4dPrice;//dex4d资产

    public String dividends;//交易分红
    public String dividendsPrice;//交易分红

    public String rebateFees;//推荐分红
    public String rebateFeesPrice;//推荐分红

    public int pending; //订单状态，几笔待确认

    public String logo;

    public List<TokenGame> tokenGames;//游戏列表

    public String getPending(Context context) {
        if (this.pending < 1) {
            return "";
        } else {
            return String.format(context.getResources().getString(R.string.dex4d_account_pending), this.pending);
        }
    }

    public CoinToken(String symbol) {
        this.symbol = symbol;
    }

    public CoinToken() {
    }

    public CoinToken(String symbol, String logo) {
        this.symbol = symbol;
        this.logo = logo;
    }

    public String getShowSymbol() {
        return symbol.toUpperCase();
    }

    @Override
    public String toString() {
        return "CoinToken{" +
                "coins='" + coins + '\'' +
                ", dex4d='" + dex4d + '\'' +
                ", dividends='" + dividends + '\'' +
                ", rebateFees='" + rebateFees + '\'' +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.symbol);
        dest.writeString(this.coins);
        dest.writeString(this.coinsPrice);
        dest.writeString(this.dex4d);
        dest.writeString(this.dex4dPrice);
        dest.writeString(this.dividends);
        dest.writeString(this.dividendsPrice);
        dest.writeString(this.rebateFees);
        dest.writeString(this.rebateFeesPrice);
        dest.writeInt(this.pending);
        dest.writeString(this.logo);
    }

    protected CoinToken(Parcel in) {
        this.symbol = in.readString();
        this.coins = in.readString();
        this.coinsPrice = in.readString();
        this.dex4d = in.readString();
        this.dex4dPrice = in.readString();
        this.dividends = in.readString();
        this.dividendsPrice = in.readString();
        this.rebateFees = in.readString();
        this.rebateFeesPrice = in.readString();
        this.pending = in.readInt();
        this.logo = in.readString();
    }

    public static final Creator<CoinToken> CREATOR = new Creator<CoinToken>() {
        @Override
        public CoinToken createFromParcel(Parcel source) {
            return new CoinToken(source);
        }

        @Override
        public CoinToken[] newArray(int size) {
            return new CoinToken[size];
        }
    };
}
